/*
 * MainWindowPresenter.h
 *
 *  Created on: May 14, 2012
 *      Author: walther
 */

#ifndef MAINWINDOWPRESENTER_H_
#define MAINWINDOWPRESENTER_H_

#include <string>
#include "Image.h"
#include <gtk/gtk.h>

//stub forward declaration
class Scene;

class MainWindowPresenter
{
public:
    /**
     * Constructor
     */
    MainWindowPresenter();
    
    /**
     * Destructor
     */
    virtual ~MainWindowPresenter();
    
    /**
     * Builds the scene from the description file
     * @param filename Path to the file
     * @return true if OK, false otherwise
     */
    bool buildScene( std::string filename );
    
    /**
     * Calls the ray tracing algorithm to render the scene into an image
     */
    void renderScene();
    
    /**
     * @return The image generated by the ray tracing algorithm
     */
    Image* getImage();
    
    /** Toggle effects */
    void toggleAmbient( bool isActive );
    void toggleDiffuse( bool isActive );
    void toggleSpecular( bool isActive );
    void toggleShadow( bool isActive );
    void toggleSoftShadow( bool isActive );
    void toggleReflection( bool isActive );
    void toggleAntiAlias( bool isActive );
    
    /**
     * Toggle regular grid
     */
    void toggleRegularGrid( bool isActive );
    
    /**
     * Rebuilds the grid with the given dimensions
     * @param nx Number of cells in the X direction
     * @param ny Number of cells in the Y direction
     * @param nz Number of cells in the Z direction
     */
    void rebuildGrid( int nx, int ny, int nz );
    
    /**
     * Sets the memory size of each ray
     * @param size Size of the memory
     */
    void setRayMemorySize( int size );
    
    bool treatKeyPress( guint keyval );
    
private:
    /** The image generated by the ray tracing algorithm */
    Image* _image;
    
    /** Scene */
    Scene* _scene;
};

#endif /* MAINWINDOWPRESENTER_H_ */
